package com.ruoyi.plan.service.impl;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ruoyi.Course.service.impl.StudyCourseServiceImpl;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.plan.mapper.StydyPlanMapper;
import com.ruoyi.plan.domain.StydyPlan;
import com.ruoyi.plan.service.IStydyPlanService;

/**
 * 复习计划Service业务层处理
 * 
 * @author luobom
 * @date 2021-12-10
 */
@Service
public class StydyPlanServiceImpl implements IStydyPlanService 
{
    @Autowired
    private StydyPlanMapper stydyPlanMapper;
    @Autowired
    StudyCourseServiceImpl studyCourseService ;

    @Override
    public List<Map<String, Object>> selectplan(String sys) {
        Map m=new HashMap();
        m.put("sys",String.valueOf(SecurityUtils.getUserId()));
        m.put("courseuid",studyCourseService.GetDefaultCourse().getUid());
        return stydyPlanMapper.selectplan(m);
    }

    /**
     * 查询复习计划
     * 
     * @param uid 复习计划主键
     * @return 复习计划
     */
    @Override
    public StydyPlan selectStydyPlanByUid(String uid)
    {
        return stydyPlanMapper.selectStydyPlanByUid(uid);
    }

    /**
     * 查询复习计划列表
     * 
     * @param stydyPlan 复习计划
     * @return 复习计划
     */
    @Override
    public List<StydyPlan> selectStydyPlanList(StydyPlan stydyPlan)
    {
        return stydyPlanMapper.selectStydyPlanList(stydyPlan);
    }

    /**
     * 新增复习计划
     * 
     * @param stydyPlan 复习计划
     * @return 结果
     */
    @Override
    public int insertStydyPlan(StydyPlan stydyPlan)
    {
        stydyPlan.setCreateBy(String.valueOf(SecurityUtils.getUserId()));
        stydyPlan.setCreateTime(DateUtils.getNowDate());
        return stydyPlanMapper.insertStydyPlan(stydyPlan);
    }

    /**
     * 修改复习计划
     * 
     * @param stydyPlan 复习计划
     * @return 结果
     */
    @Override
    public int updateStydyPlan(StydyPlan stydyPlan)
    {
        stydyPlan.setUpdateTime(DateUtils.getNowDate());
        return stydyPlanMapper.updateStydyPlan(stydyPlan);
    }

    /**
     * 批量删除复习计划
     * 
     * @param uids 需要删除的复习计划主键
     * @return 结果
     */
    @Override
    public int deleteStydyPlanByUids(String[] uids)
    {
        return stydyPlanMapper.deleteStydyPlanByUids(uids);
    }

    /**
     * 删除复习计划信息
     * 
     * @param uid 复习计划主键
     * @return 结果
     */
    @Override
    public int deleteStydyPlanByUid(String uid)
    {
        return stydyPlanMapper.deleteStydyPlanByUid(uid);
    }
}
